<?php
/*
 * Created on 2011-9-24
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 class ModelGrabLogingrab extends Model{
 	public function insert($dataarray){
		$sql='insert into ' . DB_PREFIX . 'verify_credentials SET ';
		$i=0;
		foreach($dataarray as $key => $value){
			if($i==0){
				$sql.=$key."='".$value."' ";
			}else{
				$sql.=", ".$key."='".$value."'";
			}
			$i++;
		}
		$this->log->write($sql);
 		$this->db->query($sql);
		
 	}
 	
 	public function insert_tweet($dataarray){
 		$sql='insert into ' . DB_PREFIX . 'user_timeline SET ';
		$i=0;
		foreach($dataarray as $key => $value){
			if($i==0){
				$sql.=$key."='".$value."' ";
			}else{
				$sql.=", ".$key."='".$value."'";
			}
			$i++;
		}
		$this->log->write($sql);
 		$this->db->query($sql);
		
		
 	}
	
	public function update_tweet($dataarray){
 		$sql='update ' . DB_PREFIX . 'user_timeline SET ';
		$id=array_shift($dataarray);
		$i=0;
		foreach($dataarray as $key => $value){
			if($i==0){
				$sql.=$key."='".$value."' ";
			}else{
				$sql.=", ".$key."='".$value."'";
			}
			$i++;
		}
		$sql.=" where id='".$id."'";
		$this->log->write($sql);
 		$this->db->query($sql);
		
		
 	}
 	
 	public function getVerifyById($id){
 		$query=$this->db->query("select id from ". DB_PREFIX . "verify_credentials where id='".$id."'");
 		
 		return $query;
 	}
 	
 	public function update($dataarray){
 		$sql='update ' . DB_PREFIX . 'verify_credentials SET ';
		$i=0;
		foreach($dataarray as $key => $value){
			if($i==0){
				$sql.=$key."='".$value."' ";
			}else{
				$sql.=", ".$key."='".$value."'";
			}
			$i++;
		}
		$this->log->write($sql);
 		$this->db->query($sql);
		
 	}
 }
?>
